package com.ruoyi.whzj.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.whzj.domain.WhExperiencerecord;
import com.ruoyi.whzj.service.IWhExperiencerecordService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 用户经验变动记录Controller
 * 
 * @author ruoyi
 * @date 2020-10-21
 */
@Controller
@RequestMapping("/whzj/experiencerecord")
public class WhExperiencerecordController extends BaseController
{
    private String prefix = "whzj/experiencerecord";

    @Autowired
    private IWhExperiencerecordService whExperiencerecordService;

    @RequiresPermissions("whzj:experiencerecord:view")
    @GetMapping()
    public String experiencerecord()
    {
        return prefix + "/experiencerecord";
    }

    /**
     * 查询用户经验变动记录列表
     */
    @RequiresPermissions("whzj:experiencerecord:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(WhExperiencerecord whExperiencerecord)
    {
        startPage();
        List<WhExperiencerecord> list = whExperiencerecordService.selectWhExperiencerecordList(whExperiencerecord);
        return getDataTable(list);
    }

    /**
     * 导出用户经验变动记录列表
     */
    @RequiresPermissions("whzj:experiencerecord:export")
    @Log(title = "用户经验变动记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(WhExperiencerecord whExperiencerecord)
    {
        List<WhExperiencerecord> list = whExperiencerecordService.selectWhExperiencerecordList(whExperiencerecord);
        ExcelUtil<WhExperiencerecord> util = new ExcelUtil<WhExperiencerecord>(WhExperiencerecord.class);
        return util.exportExcel(list, "experiencerecord");
    }

    /**
     * 新增用户经验变动记录
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存用户经验变动记录
     */
    @RequiresPermissions("whzj:experiencerecord:add")
    @Log(title = "用户经验变动记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(WhExperiencerecord whExperiencerecord)
    {
        return toAjax(whExperiencerecordService.insertWhExperiencerecord(whExperiencerecord));
    }

    /**
     * 修改用户经验变动记录
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        WhExperiencerecord whExperiencerecord = whExperiencerecordService.selectWhExperiencerecordById(id);
        mmap.put("whExperiencerecord", whExperiencerecord);
        return prefix + "/edit";
    }

    /**
     * 修改保存用户经验变动记录
     */
    @RequiresPermissions("whzj:experiencerecord:edit")
    @Log(title = "用户经验变动记录", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(WhExperiencerecord whExperiencerecord)
    {
        return toAjax(whExperiencerecordService.updateWhExperiencerecord(whExperiencerecord));
    }

    /**
     * 删除用户经验变动记录
     */
    @RequiresPermissions("whzj:experiencerecord:remove")
    @Log(title = "用户经验变动记录", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(whExperiencerecordService.deleteWhExperiencerecordByIds(ids));
    }
}
